<?php
App::uses('AppModel', 'Model');
class FileUpload extends AppModel {
    public $useTable = false;

    public function getAPIR($fundname)
    {
        $sql = "SELECT apir FROM apircodes where Name='".$fundname."';";
        return $this->query($sql);
    }

    public function insertIntoDB($fundname,$fundapir,$funddate,$fundvalue)
    {
        $sql = "insert into managedfunds(FundName,APIRCode,Date,Value) values ('$fundname','$fundapir','$funddate','$fundvalue');";
        $this->query($sql);
    }

    public function updateDB($fundname,$funddate,$value)
    {
        $sql="update managedfunds set value=$value where DATE='$funddate' and FundName='$fundname';";
        $this->query($sql);
    }

    public function insertIntoDBindex($indexname,$indexdate,$indexvalue)
    {
        $sql = "insert into indices(IndexName,Date,Value) values ('$indexname','$indexdate','$indexvalue');";
        $this->query($sql);
    }

    public function updateDBindex($indexname,$indexdate,$value)
    {
        $sql="update indices set value=$value where DATE='$indexname' and IndexName='$indexdate';";
        $this->query($sql);
    }
}
